﻿<UserControl x:Class="TheMovieDb.Example.Views.PersonView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:vm="clr-namespace:TheMovieDb.Example.ViewModels"
             xmlns:code="clr-namespace:TheMovieDb.Example.Converters" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.DataContext>
        <vm:PersonViewModel />
    </UserControl.DataContext>

    <UserControl.Resources>
        <code:ThumbnailConverter x:Key="thumbnailConverter" />
        <code:TextConverter x:Key="textConverter" />
        <code:PersonConverter x:Key="personConverter" />
        <code:TmdbImageConverter2 x:Key="tmdbImageConverter" />
    </UserControl.Resources>
    <Grid>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="300" />
                <ColumnDefinition Width="3" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBox Text="{Binding SearchText, Mode=TwoWay}" Margin="3" />
                    <Button Grid.Column="1" Command="{Binding SearchCommand}" Content="Search" Margin="3" />
                </Grid>

                <ListBox Grid.Row="1" ItemsSource="{Binding Persons}" SelectedItem="{Binding SelectedPerson, Mode=TwoWay}" DisplayMemberPath="Name" />
            </Grid>

            <GridSplitter Grid.Column="1" Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  />

            <ScrollViewer Grid.Column="2" HorizontalScrollBarVisibility="Disabled">
                <Grid DataContext="{Binding Person}" Margin="10">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <TextBlock Grid.Column="0" Grid.Row="0" Text="Name:" FontWeight="Bold" Margin="3" />
                    <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Name}" Margin="3" />

                    <!--<TextBlock Grid.Column="0" Grid.Row="1" Text="Also Known As:" FontWeight="Bold" Margin="3" />
                    <ItemsControl Grid.Column="1" Grid.Row="1" ItemsSource="{Binding AlsoKnownAs.Names}" Margin="3">
                    </ItemsControl>-->

                    <TextBlock Grid.Column="0" Grid.Row="2" Text="Popularity:" FontWeight="Bold" Margin="3" />
                    <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding Popularity}" Margin="3" />

                    <TextBlock Grid.Column="0" Grid.Row="3" Text="Score:" FontWeight="Bold" Margin="3" />
                    <TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding Score}" Margin="3" />

                    <TextBlock Grid.Column="0" Grid.Row="4" Text="Url:" FontWeight="Bold" Margin="3" />
                    <TextBlock Grid.Column="1" Grid.Row="4" Text="{Binding Url}" Margin="3" Tag="{Binding Url}" TextDecorations="Underline" Foreground="Blue" Cursor="Hand" MouseLeftButtonUp="TextBlockMouseLeftButtonUp" />

                    <TextBlock Grid.Column="0" Grid.Row="5" Text="Birthday:" FontWeight="Bold" Margin="3" />
                    <TextBlock Grid.Column="1" Grid.Row="5" Text="{Binding Birthday,StringFormat=d}" Margin="3" />

                    <TextBlock Grid.Column="0" Grid.Row="6" Text="Birthplace:" FontWeight="Bold" Margin="3" />
                    <TextBlock Grid.Column="1" Grid.Row="6" Text="{Binding Birthplace}" Margin="3" />

                    <TextBlock Grid.Column="0" Grid.Row="7" Text="Biography:" FontWeight="Bold" Margin="3" />
                    <TextBlock Grid.Column="1" Grid.Row="7" Text="{Binding Biography}" Margin="3" />

                    <TextBlock Grid.Column="0" Grid.Row="8" Text="Known Movies:" FontWeight="Bold" Margin="3" />
                    <TextBlock Grid.Column="1" Grid.Row="8" Text="{Binding KnownMovies}" Margin="3" />

                    <TextBlock Grid.Column="0" Grid.Row="9" Text="Filmagraphy:" FontWeight="Bold" Margin="3" />
                    <ItemsControl Grid.Column="1" Grid.Row="9" ItemsSource="{Binding Filmography}" Margin="3">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Border BorderBrush="Black" CornerRadius="3" BorderThickness="1" Margin="2">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="150" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>

                                        <Image Source="{Binding Poster}" Margin="5" />
                                        <Grid Margin="2" Grid.Column="1">
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="Auto" />
                                            </Grid.RowDefinitions>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="*" />
                                            </Grid.ColumnDefinitions>

                                            <TextBlock Grid.Column="0" Grid.Row="0" Text="Movie:" Margin="1" />
                                            <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Name}" Margin="1" />

                                            <TextBlock Grid.Column="0" Grid.Row="1" Text="Job:" Margin="1" />
                                            <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Job}" Margin="1" />

                                            <TextBlock Grid.Column="0" Grid.Row="2" Text="Character:" Margin="1" />
                                            <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding Character}" Margin="1" />
                                        </Grid>
                                    </Grid>
                                </Border>

                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>

                    <TextBlock Grid.Column="0" Grid.Row="10" Text="Images:" FontWeight="Bold" Margin="3" />
                    <ItemsControl Grid.Column="1" Grid.Row="10" ItemsSource="{Binding Images,Converter={StaticResource tmdbImageConverter},ConverterParameter='profile'}" Margin="3">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="{Binding ImageInfo.Url}" Margin="5" HorizontalAlignment="Center" />
                                </StackPanel>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </Grid>
            </ScrollViewer>
        </Grid>
    </Grid>
</UserControl>
